<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="fragments/head :: head"></head>
<body >
<div th:replace="fragments/top-nav :: header-nav"></div>
<div class="main-container" id="main-container">
	<div class="main-container-inner">
		<div class="main-content mayi-rsm-main-content">
			<div class="page-content">
				<div class="row">
					<div class="col-xs-12">
						<form class="form-horizontal" id="submitForm">

							<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right text-warning" >账号*</label>
								<div class="col-sm-9">
									<input type="text" id="id" name="id" class="col-xs-10 col-sm-5" />
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right text-warning" >名称*</label>
								<div class="col-sm-9">
									<input type="text" id="name" name="name" class="col-xs-10 col-sm-5" />
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right text-warning" >密码*</label>
								<div class="col-sm-9">
									<input type="text" id="password" name="password" value="a123456" class="col-xs-10 col-sm-5" />
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label no-padding-right text-warning" >角色*</label>
								<div class="col-sm-9 checkbox">
									<label th:each="item : ${adminRoles}"   >
										<input name="roles" class="ace ace-checkbox-2" th:value="${item.key}" type="checkbox"/>
										<span class="lbl" th:text="${item.value}"> </span>
									</label>
								</div>
							</div>
							<div class="clearfix form-actions">
								<div class="col-md-offset-3 col-md-9">
									<button class="btn btn-info" type="button" onclick="add()">
										<i class="icon-ok bigger-110"></i>
										提交
									</button>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<div th:replace="fragments/footer :: footer"></div>
<script  type="text/javascript"  th:src="@{/js/ace/date-time/bootstrap-datepicker.min.js}"></script>
<script th:inline="javascript">
	$(function(){
		$(".date-picker").datepicker({autoclose:true});
		$("#id").change(function (){
			check.checkEmpty("id");
		});
		$("#name").change(function (){
			check.checkEmpty("name");
		});
		$("#password").change(function (){
			check.checkEmpty("password");
		});
	});

	function validateRoles(){
		var size = $("input[name='roles']:checked").size();
		var result =  size >= 1;
		if(!result){
 			common.modalGlobalMessage("请设定角色!","错误");
		}

		return result;

	}
	function add(){
		/*<![CDATA[*/
	 	if(check.checkEmpty("id")
	 	 & check.checkEmpty("name")
	 	  & check.checkEmpty("password")
	 	 & validateRoles()
	 	 ){
			var uri = /*[[@{/admin/user/add}]]*/;
			common.ajaxSubmit(uri,'submitForm','保存失败','保存成功','addSucc()');
		}
		/*]]>*/
	}
	function addSucc(){
		var uri = /*[[@{/admin/user/list}]]*/;
		common.reload(uri);
	}
</script>
</body>
</html>
